import java.util.ArrayList;
import java.util.Random;
import java.util.Locale;

public class RandomGenerator {
	private ArrayList<String> randomName;
	private ArrayList<String> randomCountry;
	private ArrayList<String> randomGenre;
	private ArrayList<String> Country;
	private Random rnd;
	static String[] genreList = { "Rock", "Pop", "Country", "Western",
			"Electronic", "Blues", "Children", "Classical", "Folk",
			"Traditional", "Jazz", "R&B", "Hip Hop", "Rap",

			"Religious", "Latino", "Salsa", "Metal", "Tribal", "Disco",
			"Dance", "Rock'n'Roll", "Punk", "Funk", "Opera", "Acoustic",
			"Soul",

	};

	public RandomGenerator() {
		randomName = new ArrayList<String>();
		randomCountry = new ArrayList<String>();
		randomGenre = new ArrayList<String>();
		Country = new ArrayList<String>();
		rnd = new Random();
	}

	public ArrayList<String> generateRandomCountry() {
		Locale[] locales = Locale.getAvailableLocales();
		for (Locale locale : locales) {
			String name = locale.getDisplayCountry()+"";

			if (!"".equals(name)) {
				Country.add(name);
			}
		}
		for (int i = 0; i <= 100; i++) {
			int randomLength = getRandomLength(Country.size()) ;
			
			String s = Country.get(randomLength);
			randomCountry.add(s);
		}

		return randomCountry;

	}

	public ArrayList<String> generateRandom() {
		for (int i = 0; i <= 100; i++) {
			int randomLength = getRandomLength(7) + 1;
			String s = giveMeString(randomLength);
			System.out.println(s + " ");
			randomName.add(s);
		}

		return randomName;

	}

	public ArrayList<String> generateRandomGenre() {
		for (int i = 0; i <= 100; i++) {
			System.out.println(genreList.length);
			int randomLength = getRandomLength(genreList.length);
			String s = genreList[randomLength];
			randomGenre.add(s);
		}
		return randomGenre;

	}

	private String giveMeString(int randomLength) {
		// TODO Auto-generated method stub
		String returnString = new String();
		int i;
		int randomAscii;
		for (i = 0; i < randomLength; i++) {
			randomAscii = getRandomLength(25);
			returnString = returnString + (char) (randomAscii + 97);

		}
		return returnString;
	}

	private int getRandomLength(int length) {
		// TODO Auto-generated method stub
		int x = rnd.nextInt(length);
		while (x == 1 || x == 2)
			x = rnd.nextInt(length);
		return rnd.nextInt(length);
	}

}
